<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>鑫多多</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../css/mui.min.css">
		<link href="../css/icons-extra.css" rel="stylesheet" />
		<link href="../css/iconfont.css" rel="stylesheet" />
		<link href="../css/style.css" rel="stylesheet" />
		
		<style type="text/css">
			[ng-cloak] {
				display: none;
			}
			.mui-btn-royal.active{
				color: #fff !important;
				background-color:#8a6de9;
			}
		</style>

		<script src="../js/angular/angular.min.js"></script>
		<script src="../js/angular/angular-resource.js"></script>
		<script src="../js/angular/common.js"></script>
		<script src="../js/mui.min.js"></script>
		<script src="../js/common.js"></script>
		<script src="../js/service/qfMsgListService.js"></script>
		<script src="../js/service/goodsService.js"></script>
		<script src="../js/service/userService.js"></script>
	</head>

	<body ng-app="mainApp" ng-controller="qfMsgListCtrl">
		<header class="mui-bar mui-bar-nav mui-bar-in">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<!--<div class="mui-input-row mui-search ">
				<input type="search" class="mui-input-clear" placeholder="" ng-model="orderSearch" placeholder="消息名称">
			</div>
			<a class="mui-icon mui-pull-right right" ng-click="qfMsgSearchBtn()">搜索</a>-->
		</header>
		<!-- 主页面内容容器 -->
		<div class="mui-content order-content mui-scroll-wrapper" id="pullrefresh">
			 <div class="mui-scroll">
			 	<!-- 主界面具体展示内容 -->
				<div class="mui-card order_wrap" >
					<ul class="mui-table-view">
	
						<li class="mui-table-view-cell mui-collapse  order nimamage" ng-repeat="order in qfMsgList_" ng-click="tradeStateChange(order.id)" on-finish-render-filters>
							<a class="mui-navigate-right order_top" href="javascript:;" id="{{order.id}}">
								<span class="mui-pull-left mui-col-xs-7">标题:{{order.title}}</span>
								<span class="mui-pull-left mui-col-xs-3 username">{{order.inputUserName}}</span>
								<span ng-if="order.state=='1'" class="mui-pull-right state mui-col-xs-2" style="color: green;">已读</span>
								<span ng-if="order.state=='0'" class="mui-pull-right state mui-col-xs-2">未读</span>
							</a>
							
							<ul class="mui-table-view cart order_con">
								<li class="mui-table-view-cell mui-media" >
									<div class="mui-right" style=" border-bottom: none;" >
										<div class="mui-pull-left" >
											<img ng-show="order.imgUrl" class="mui-media-object"  src="{{baseUrl+'/dapi/download/getImageIO?imgUrl='+order.imgUrl|getImgUrl}}" >
											<img ng-show="!order.imgUrl" class="mui-media-object" ng-src="../images/goodsDefault.gif">
										</div>
										<div>
											<p ng-if="order.content!=null">&nbsp;&nbsp;&nbsp;{{order.content}}</p>
										</div>
									</div>
								</li>
								<li class="mui-table-view-cell mui-media value_box">
									<div class="order_btn">
										<button type="button" class="mui-btn mui-btn-danger mui-btn-outlined " ng-click="deleteQfMsg(order.id)">删除</button>
									</div>
								</li>
							</ul>
						</li>
					</ul>
				</div>
			 </div>
			

		</div>
		<script type="text/javascript ">
			mui.init({
    			beforeback: function() {
　　　　 			//获得父页面的webview
        		var list = plus.webview.currentWebview().opener();
　　　　 			//触发父页面的自定义事件(refresh),从而进行刷新
        		mui.fire(list, 'refresh');
        		//返回true,继续页面关闭逻辑
        		return true;
    			}
			});

			mui('.bottomPopover').popover('toggle'); //show hide toggle
		</script>
		<script>
			(function($) {
				$.init({
					swipeBack: true //启用右滑关闭功能
				});
				$(".mui-scroll-wrapper").scroll({
					bounce: false, //滚动条是否有弹力默认是true
					indicators: true, //是否显示滚动条,默认是true
				});
			})(mui);
			mainApp.controller('qfMsgListCtrl', function($scope, $http, qfMsgListService,userService,goodsService) {
				
				mui.init({
					pullRefresh: {
						container: '#pullrefresh',
						down: {
							//callback: pulldownRefresh
						},
						up: {
							contentrefresh: '正在加载...',
							callback: pullupRefresh
						}
					}
				});
				 mui('body').on('tap', '.nimamage a', function() {
				 	var id=this.getAttribute("id");
            		qfMsgListService.updateQfMsgStatus(id,function () {
                        },error)
        		});
				function pullupRefresh() {
					setTimeout(function() {
						qfMsgList();
						mui('#pullrefresh').pullRefresh().endPullupToRefresh(); //refresh completed
					}, 1000);
				}
				$scope.qfMsgParam={}
				mui.plusReady(function(){
			    var self = plus.webview.currentWebview();
			    var state=self.state;
			    if(state!=undefined){
			    	$scope.qfMsgParam.state=state;
			    	qfMsgList();
			    }
				});
				
				$scope.baseUrl = baseUrl;
				$scope.pageIndex = 1;
				$scope.pageSize = 15;
				$scope.qfMsgList_=null;
				var qfMsgList=function(){
					qfMsgListService.getQfMsgList($scope.qfMsgParam, $scope.pageIndex, $scope.pageSize, function(data) {
						var qfMsgList=data.data.list;
						if($scope.pageIndex == 1){
							$scope.qfMsgList_=qfMsgList;
						}else{
							angular.forEach(qfMsgList, function(order) {
								$scope.qfMsgList_.push(order);
							});
						}
						if(qfMsgList.length>0){
							$scope.pageIndex = $scope.pageIndex + 1;
						}
					}, error)
				}
				
				
			
				//删除订单
				$scope.deleteQfMsg=function(id){
						qfMsgListService.deleteQfMsgStatus(id,function(){
							angular.forEach($scope.qfMsgList_,function(item,index){
								if(id==item.id){
									$scope.qfMsgList_.splice(index,1);
								}
							})
						},error);
				}
				$scope.qfMsgSearchBtn=function(){
					$scope.pageIndex=1;
					qfMsgList();
				}
			});
		</script>
	</body>
</html>